﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Linq;
using System.Collections.ObjectModel;
using System.Collections.Specialized;
using System.ComponentModel;

namespace Marking.Dashboard.ViewModels.Finance
{
    public class FinancePieChartViewModel : ObservableCollection<FinanceInfo>
    {
        public FinancePieChartViewModel(string titleFormator)
        {
            this.TitleFormator = titleFormator;
        }

        /// <summary>
        /// 图表中显示的的标题格式。
        /// </summary>
        public string TitleFormator { get; private set; }

        /// <summary>
        /// 图表中显示的的标题。
        /// </summary>
        public string Title
        {
            get
            {
                return string.Format(this.TitleFormator, this.Sum(x => x.Quantity));
            }
        }

        protected override void OnCollectionChanged(NotifyCollectionChangedEventArgs e)
        {
            base.OnCollectionChanged(e);

            this.OnPropertyChanged(new PropertyChangedEventArgs("Title"));
        }
    }
}
